package br.com.gaacorp.sai.model;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
@Table(name = "tab_matter")
public class Matter extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4110478936810327976L;
	private Long matterId;
	private String name;
	private String description;
	private Course course;

	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (!(o instanceof Matter)) {
			return false;
		}

		final Matter matter = (Matter) o;

		return !(name != null ? !name.equals(matter.name) : matter.name != null);
	}

	@ManyToOne(optional = false)
	@OnDelete(action = OnDeleteAction.CASCADE)
	public Course getCourse() {
		return course;
	}

	public String getDescription() {
		return description;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getMatterId() {
		return matterId;
	}

	public String getName() {
		return name;
	}

	public int hashCode() {
		return (name != null ? name.hashCode() : 0);
	}

	public void setCourse(Course course) {
		this.course = course;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setMatterId(Long matterId) {
		this.matterId = matterId;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).append(
				this.name).toString();
	}

}
